package com.autoai.nginx.demo;

import com.google.gson.Gson;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/nginx")
public class HelloController {
    public static Gson gson = new Gson();
    public static final String TF = "yyyy-MM-dd HH:mm:ss.SSS";

    @PostMapping("/testPost")
    public String testPost(@RequestParam Map<String, Object> params) {
        params.put("status", 200);
        params.put("timestamp", new SimpleDateFormat(TF).format(new Date()));
        return gson.toJson(params);
    }

    @GetMapping("/testGet")
    public String testGet(@RequestParam Map<String, Object> params) {
        params.put("timestamp", new SimpleDateFormat(TF).format(new Date()));
        params.put("status", 200);
        return gson.toJson(params);
    }

}
